#include "stdafx.h"
#include "gtest/gtest.h"
TEST(case1, test1) {
	std::cout << my_strcat("abc", "def") << std::endl;
	std::cout << my_strcat("abc", "") << std::endl;
	std::cout << my_strcat("abc", NULL) << std::endl;
	std::cout << my_strcat(NULL, "abc") << std::endl;
	std::cout << my_strcat(NULL, NULL) << std::endl;
	system("pause");
}
#include<iostream>
#include<stdlib.h>
using namespace std;
char* strcat(char* str1, char* str2)
{
	if (str1 == NULL)
	{
		return str2;
	}
	if (str2 == NULL)
	{
		return str1;
	}
	int i = 0, j = 0;
	while (str1[i])
	{
		i++;
	}
	while (str2[j])
	{
		j++;
	}
	char* temp = (char*)malloc((i + j + 1) * sizeof(char));
	char* str = temp;
	while (*str1 != '\0')
	{
		*str++ = *str1++;
	}
	while (*str2 != '\0')
	{
		*str++ = *str2++;

	}
	*str = '\0';
	return temp;
}
int main()
{
	testing::InitGoogleTest(&argc, argv)
		return RUN_ALL_TESTS();
}
